<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								代理商名称：
									<input id="agentName" name="agentName"  />
									<input  type="hidden" id="agentNameList" value=""/><br>
							</li>
							<li>
								代理商手机号：<input type="text" name="corpPhone"/>
							</li>
							<!--
							<li>
								代理商编号：<input type="text" name="agentNo"/>
							</li>
							<li>
								上级代理名称：
								<input id="parentId" name="parentId"/>
								<input type="hidden" id = "parentIdList" value=""/><br>
							</li>
							 <li>
								代理商级别：<select name="tYPE" th:with="type=${@dict.getType('agent_level')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li> 
							 <li>
								使 用 状 态：<select name="employStatus" th:with="type=${@dict.getType('agent_employStatus')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li> 
							<li>
								代理商关系：<select name="direct" th:with="type=${@dict.getType('agent_direct')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							-->
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
	       <!--  <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:hatchetAgent:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:hatchetAgent:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:hatchetAgent:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:hatchetAgent:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div> -->
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
       /*  var editFlag = [[${@permission.hasPermi('system:hatchetAgent:edit')}]];
       	var removeFlag = [[${@permission.hasPermi('system:hatchetAgent:remove')}]]; */
        /* var detailFlag = [[${@permission.hasPermi('system:hatchetAgent:detail')}]]; */
        //查询字典表
       	var types = [[${@dict.getType('agent_level')}]];
        var employStatus = [[${@dict.getType('agent_employStatus')}]];
        var detailFlag = [[${@permission.hasPermi('system:hatchetAgent:detail')}]];
        var prefix = ctx + "system/hatchetAgent";
      	var agentNameList = [];
        $(function() {
        	agents();
         	//代理商名称自动补全
         	$("#agentName").autocomplete({
        		source: agentNameList
        	});
         	$("#parentId").autocomplete({
        		source: agentNameList
        	});
            var options = {
                url: prefix + "/ForDLSlist",
               	/* createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
             	removeUrl: prefix + "/remove", */
             	detailUrl: prefix + "/detailForDLS/{id}",
             	showRelationUrl: prefix + "/showRelation/{id}",
				exportUrl: prefix + "/export", 
                modalName: "代理商",
				search: false,
		        showExport: false,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : 'ID',
					visible: false
				},
				{
					field : 'agentNo', 
					title : '代理商编号',
					sortable: false
				},
				{
					field : 'agentName', 
					title : '代理商名称',
					sortable: false
				},
				{
					field : 'tYPE', 
					title : '代理商等级',
					align : 'left',
					formatter: function(value, item, index) {
			            return $.table.selectDictLabel(types, item.type);
			            }
				},
				{
					field : 'corpName', 
					title : '名称',
					sortable: false
				},
				{
					field : 'corpPhone', 
					title : '手机号',
					sortable: false
				},
				{
					field : 'createTime', 
					title : '代理商创建时间',
					sortable: true
				},
				
				{
					field : 'parentId', 
					title : '上级代理商',
					sortable: false
				},
				/* {
					field : 'employStatus', 
					title : '使用状态',
					align: 'center',
					formatter: function(value, row, index) {
			            	return $.table.selectDictLabel(employStatus, value);
			            }
				}, */
				{
					field : 'fastCount', 
					title : '升级码数量',
					sortable: true
				},
				
				{
					field : 'totalMoney', 
					title : '账户余额(元)',
					sortable: true
				} ,
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detail(\'' + row.id + '\')">查看详情</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
            
          //查找代理商下面的所有代理商
     		function agents(){
        		var array=[];
    			$.ajax({
    				url: prefix+"/getAgentAllForDLS",
    				async:false,
    				type:"POST",
    				data:{},
    				success: function(result) {
    					$.each(result, function(i,v) {
    						if (v.agentName != null && v.agentName != undefined) {
    							agentNameList.push(v.agentName);
    							var arrays = {};
    							arrays.value = v.agentName;
    							arrays.id = v.id;
    							array.push(arrays);
    						}
    					});
    				}
    			});
    			return array;
        	} 
            
        });
    </script>
</body>
</html>